﻿//  -------------------- iSharePoint -------------------- //
// 
//  Company:	IT Complex, LLC
//  Project:	Smart.Documents
//  File name:	AddonDocuments.cs
//  Developer:	Solomatov Igor
//  Created:	16.04.2012
// 
//  -------------------- iSharePoint -------------------- //

using Microsoft.SharePoint;
using Smart.Common;
using Smart.Common.Entities;
using Smart.Common.Forms;
/*
using Smart.Common.Templates;
using Smart.Documents.Managers;
using Smart.Documents.Scopes;
using Smart.Documents.Services;
 */

namespace Smart.Documents
{
	public class AddonDocuments : Addon
	{
		public override void Register()
		{
			var config = SPServices.Configuration;
			var rootWeb = SPH.GetRootWeb();

			/*
			// Org structure
			var oScope = new OrgStructureContext();
			oScope.SetDefaultSettings(config, rootWeb, Const.ScopeNames.OrgStructure, Const.ScopeNames.OrgStructure);

			// Documents
			var dScope = new DocumentsContext();
			dScope.SetDefaultSettings(config, rootWeb, Const.ScopeNames.Documents, Const.ScopeNames.Documents);

			// Assignments
			var aScope = new AssignmentsContext();
			aScope.SetDefaultSettings(config, rootWeb, Const.ScopeNames.Assignments, Const.ScopeNames.Assignments);

			// WorkingSchedule
			var wsScope = new WorkingScheduleContext();
			wsScope.SetDefaultSettings(config, rootWeb, Const.ScopeNames.WorkingSchedule, Const.ScopeNames.WorkingSchedule);
			 */
		}

		public override void Load()
		{
			/*
			// Org structure
			EntityFactory.Register<Employee>();
			EntityFactory.Register<Department>();
			EntityFactory.Register<DepartmentUrl>();

			Context.Register<OrgStructureContext, IOrgStructureContext>(Const.ScopeNames.OrgStructure);

			// Word templates
			EntityFactory.Register<WordTemplate>();
			EntityFactory.Register<WordInstance>();

			TemplateFactory.Register<WordTemplateService, WordTemplate, WordInstance>(Const.Templates.Word.ServiceName);

			// Assignments
			EntityFactory.Register<Assignment>();
			EntityFactory.Register<AssignmentApprove>();
			EntityFactory.Register<AssignmentRead>();

			Context.Register<AssignmentsContext, IAssignmentsContext>(Const.ScopeNames.Assignments);

			// WorkingSchedule
			EntityFactory.Register<WorkingSchedule>();
			Context.Register<WorkingScheduleContext, IWorkingScheduleContext>(Const.ScopeNames.WorkingSchedule);

			// Documents
			EntityFactory.Register<RequiredDocumentType>();
			EntityFactory.Register<DocumentType>();
			EntityFactory.Register<DocumentForm>();
			EntityFactory.Register<BaseStatus>();

			Context.Register<DocumentsContext, IDocumentsContext>(Const.ScopeNames.Documents);

			// List forms
			FormsFactory.Register<ListFormsService>(Common.Const.Forms.WebForms.ListFormsServiceName);

			// PrivateOffice forms
			FormsFactory.Register<PrivateOfficeService>(Const.PrivateOffice.PrivateOfficeServiceName);

			// SubWebManagement
			// Setup content default
			SPServices.EventManager.Register(
				Const.SubWebManager.EventNames.SetupContent, 500,
				new NamedEventHandler<SPWeb>(SetupContentDefault));
			// Setup security default
			SPServices.EventManager.Register(
				Const.SubWebManager.EventNames.SetupSecurity, 500,
				new NamedEventHandler<SPWeb>(SetupSecurityDefault));
			 */
		}

		/*
		/// <summary>
		/// Setup content by default (using Documents scope)
		/// </summary>
		public static bool SetupContentDefault(string eventName, SPWeb web)
		{
			SubWebManager.SetupContentUsingDocuments(web, null, null, null, null);
			SubWebManager.SetupAssignmentsContent(web);

			return true;
		}

		/// <summary>
		/// Setup security by default (using Documents scope)
		/// </summary>
		public static bool SetupSecurityDefault(string eventName, SPWeb web)
		{
			SubWebManager.SetupSecurityUsingDocuments(web);

			return true;
		}
		 */
	}
}